n = 20;
alpha = 0.01
# x = rnorm(n, mean=10, sd=1)
x = c(10.918336619803, 9.78596209459807, 9.67462378395824, 9.64261465421377, 
      10.3860660840151, 10.8306626795131, 10.7385771367153, 9.28175211817219, 
      7.97647458334142, 11.3521899016227, 8.30047009053018, 10.2535937632752, 
      10.4338472854822, 10.1500273858907, 8.88768784756262, 8.75503277592648, 
      9.73221415241088, 11.00047907129, 10.8039193961326, 10.6424688262473
)
# error = rnorm(n, mean=0.5, sd=0.8306624)
error = c(0.658328504058829, -0.315324197993121, 1.30087936173164, 0.591693698085935, 
          -0.692493487988883, -0.372483865522903, 1.00828056799908, 0.607801241140833, 
          -0.225513270669598, 0.237668190391233, 0.168612563777055, 1.34471124332578, 
          -0.0290538482456432, -0.293405194161065, 1.45903506402552, 1.50465833199438, 
          -1.44255685475379, 0.738912087546399, 1.20343223027399, 1.26537016744944
)

y = x + error
t.test(x, y=y, paired = TRUE, alternative = "less", conf.level = 1-alpha)

xBar = mean(x)
yBar = mean(y)

diffBar = xBar - yBar
diffVar = sd(x)^2+sd(y)^2 - 2* cov(x=x,y=y)
t = ((diffBar)/sqrt(diffVar))*sqrt(n)
qt = qt(alpha,df=19)
t
# zamitam pro t < -qt
qt
